package com.todaynews.ui.smallvideo.adapter;

import android.view.View;
import android.widget.ImageView;
import com.bumptech.glide.Glide;
import com.todaynews.R;
import com.todaynews.frame.ui.views.brvah.BaseQuickAdapter;
import com.todaynews.frame.ui.views.brvah.BaseViewHolder;
import com.todaynews.model.model.SmallVideo;
import com.todaynews.ui.smallvideo.VideoPlayActivity;
import com.todaynews.ui.smallvideo.transition.TransitionParam;
import com.todaynews.ui.smallvideo.transition.TransitionUtils;

import java.util.List;

/**
 * @description: 视频列表的Adapter
 */

public class SmallVideoListAdapter extends BaseQuickAdapter<SmallVideo, BaseViewHolder> {

    public SmallVideoListAdapter(List<SmallVideo> data) {
        super(R.layout.fragment_small_video_list_item, data);
    }

    @Override
    protected void convert(BaseViewHolder helper, SmallVideo smallVideo) {
        helper.setText(R.id.tv_desc, smallVideo.getDesc());//设置标题
        helper.setText(R.id.tv_num, smallVideo.getPlayerNums()+"次播放");//设置播放次数
        helper.setText(R.id.tv_praise, smallVideo.getPraiseNums()+"赞");//设置赞
        Glide
            .with(mContext)
            .load(smallVideo.getPath())
            .centerCrop()
            .placeholder(R.drawable.b9b)
            .into((ImageView) helper.getView(R.id.iv_src));

        ImageView imageView = helper.getView(R.id.iv_src);
        imageView.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                TransitionParam animBean = TransitionUtils.getSourceViewParam(view);
                VideoPlayActivity.intentStart(view.getContext(), animBean);
            }
        });
    }
}
